﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BlueLotus7.Common
{
    public class EntityMappingCollection : List<EntityMapping>
    {
        public int IndexOfByKey(Guid key)
        {
            int result = -1;


            for (int i = 0; i < this.Count; i++)
            {
                EntityMapping entity = this[i];
                if (entity != null && entity.Key == key)
                {
                    result = i;
                    break;
                }
            }

            return result;
        }

        public bool ContainByKey(Guid key)
        {
            int index = IndexOfByKey(key);
            return index > -1;
        }

        public bool RemoveByKey(Guid key)
        {
            bool result = false;

            int index = this.IndexOfByKey(key);
            if (index > -1)
            {
                this.RemoveAt(index);
                result = true;
            }

            return result;
        }
    }
}
